package com.todo.event.activity.iface.backend.common;


import com.todo.common.utils.StringUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * @author azhebuxing
 * @date 2025/1/11 12:33
 * @description
 */
@Data
@Schema(description = "活动规则")
public class ActivityRule {

    @Schema(title = "是否黑名单验证", description = "是否黑名单验证")
    private Boolean hitBlackList;

    @Schema(title = "黑名单所属分类", description = "黑名单所属分类")
    private String blackClassify;

    @Schema(title = "执行频次", description = "执行频次 n天/n次")
    private Frequency frequency;

    @Schema(title = "是否人群验证", description = "是否人群验证")
    private Boolean hitCrowd;

    @Schema(title = "人群分类", description = "人群分类")
    private String crowdClassify;

    @Data
    public static class Frequency {

        @Schema(title = "天数", description = "天数")
        private Integer day;

        @Schema(title = "次数", description = "次数")
        private Integer count;
    }

    public boolean baseCheck() {
        if (hitBlackList && StringUtils.isBlank(blackClassify)){
            return false;
        }
        if (hitCrowd && StringUtils.isBlank(crowdClassify)){
            return false;
        }
        if (frequency == null){
            return false;
        }
        return true;
    }
}
